<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/1/31 0031
 * Time: 下午 16:10
 */

namespace app\admin\controller;

use app\admin\model\Order  as A;
use think\Cache;
class Order extends  Common
{
    private $PageTitle ;
    //实例化model
    protected $db;
    protected function _initialize()
    {
        parent::_initialize();
        $this->db= new A();
    }
    
    public function index()
    {
        /*$appcode='bd2f0644074f4ffab2ddb4d5c6ffef46';
        $number='469199244759';
        $res=wuliu($appcode,$number);
        $string="{\"status";
        $res=(explode($string,$res));
        $res=$string.$res[1];
        Cache::set('wuliu',$res,3600);*/
        //var_dump($wuliu);
        $allData=$this->db->getAllOrderData();
        //halt($allData);
        $this->assign('allData',$allData);
        $this->PageTitle='订单管理';
        $this->generalInfor($this->PageTitle);
        return $this->fetch();
    }
    public function getLogisticsInfo()
    {

        if(request()->isPost())
        {
            //halt($_POST);
            $res=$this->db->addLogisticsInfo(input('post.'));
            $mess=array(
                'status'=>$res['valid'],
                'message'=>$res['msg']
            );
            return $mess;
        }
        return $this->fetch();
    }
    public function  getWuliuCompany()
    {

        $res=Cache::get('wuliuCompang');
        if($res)
        {
            $res=Cache::get('wuliuCompang');
        }else
            {
                $appcode='bd2f0644074f4ffab2ddb4d5c6ffef46';
                $res=wuliuCompany($appcode);
                $string="{\"status";
                $res=(explode($string,$res));
                $res=$string.$res[1];
                Cache::set('wuliuCompang',$res,0);
                $res=Cache::get('wuliuCompang');
            }
        var_dump(json_decode($res));
        halt($res);
    }
    public function phoneYan()
    {
        $appcode='bd2f0644074f4ffab2ddb4d5c6ffef46';
        $mobile='18329479874';
        $tpl_id='TP1803139';
        $id=input('param.id');
        //$msg="【电商】,您在微信小程序有一笔订单30分钟后失效，请及时支付,有问题请拨400-80000,祝您生活愉快";
        $tel='4000-80000';
        $code=30;
        $res=phoneYan($appcode,$mobile,$code,$tel,$tpl_id);
        halt($res);
        return json_encode($res);
    }
    //上传订单号
    public function upodate_log()
    {
        $res=(new A())->upodate_log(input('param.'));
        $mess=array(
            'status'=>$res['valid'],
            'message'=>$res['msg']
        );
        return $mess;
    }

}